#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long LL;
LL n,m,T,L,V,d[N],v[N],a[N],p[N],k=1;bool f=0;

bool is[N];
struct node{int l,r;}e[N];
int twicen(double x){
    int l=1,r=m,mid;f=0;
    while(l<=r){
        mid=l+r>>1;
        if(p[mid]==x) return mid;
        else if(p[mid]<x) l=mid+1;
        else r=mid-1;
    }f=1;return l-1;
}
bool cmp(node x,node y){
    return x.l<y.l||(x.l==y.l&&x.r<y.r);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        int ans=0;k=1;
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
            is[i]=0;
        }
        for(int i=1;i<=m;i++) scanf("%d",&p[i]);
        for(int i=1;i<=n;i++){
            double xx=(V*V-v[i]*v[i])*1.0/2/a[i]+d[i]*1.0;
            e[k].l=e[k].r=-1;
            if(v[i]>V){e[k].l=twicen(d[i])+f;
                if(a[i]>=0) e[k].r=m;
                else{
                    e[k].r=twicen(xx);
                    if(!f)e[k].r--;
                }
            }else if(a[i]>0){
                e[k].l=twicen(xx)+f;
                e[k].r=m;
            }
            if(e[k].l==-1||e[k].l>e[k].r) continue;
            ans++,k++;
        }printf("%d ",ans);sort(e+1,e+k,cmp);int la=0,cnt=0;
       for(int i=1;i<k;i++){
            for(int j=1;j<k;j++){
                if(i==j) continue;
                if(e[i].l<=e[j].l&&e[i].r>=e[j].r){
                    is[i]=1;break;
                }
            }
        }
        for(int i=1;i<k;i++){
            if((la<e[i].l||la>e[i].r)&&is[i]==0){
                la=e[i].r,cnt++;
            }
        }printf("%lld\n",m-cnt);
    }
    fclose(stdin);fclose(stdout);
    return 0;
}
